package exam.xiecheng;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = 0;
        int [][] time = new int[n][3]; //0表示开始1表示结束2表示价值
        for (int i = 0; i < n; i++) {
            time[i][0] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            time[i][1] = scanner.nextInt();
            m = Math.max(m,time[i][1]);
        }
        for (int i = 0; i < n; i++) {
            time[i][2] = scanner.nextInt();
        }
        Arrays.sort(time, (o1, o2) -> {
            if(o1[0]!=o2[0]){
                return o1[0]-o2[0];
            }
            else{
                return o1[1]-o2[1];
            }
        });
        int []dp = new int[m+1];
        dp[1] = time[0][2];
        for (int i = time[0][1]; i <=m ; i++) {
            dp[i] = time[0][2];
        }
        for (int i = 1; i < n; i++) {
            for (int j = m; j >= time[i][1]; j--) {
                dp[j] = Math.max(dp[j],dp[time[i][0]]+time[i][2]);
            }
            
        }
        System.out.println(dp[m]);
    }
}
